﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using TyMES.Model.Record;
using TyMES.Model;

namespace TyMES.ViewModel.Record.TrayBindVSNVMs
{
    public partial class TrayBindVSNListVM : BasePagedListVM<TrayBindVSN_View, TrayBindVSNSearcher>
    {
        
        protected override IEnumerable<IGridColumn<TrayBindVSN_View>> InitGridHeader()
        {
            return new List<GridColumn<TrayBindVSN_View>>{
                
                this.MakeGridHeader(x => x.TrayBindVSN_TrayCode).SetTitle(@Localizer["Page.托盘编码"].Value),
                this.MakeGridHeader(x => x.TrayBindVSN_VSN).SetTitle(@Localizer["Page.虚拟sn"].Value),
                this.MakeGridHeader(x => x.TrayBindVSN_ScheduleCode).SetTitle(@Localizer["Page.排程号"].Value),
                this.MakeGridHeader(x => x.TrayBindVSN_orderCode).SetTitle(@Localizer["Page.工单号"].Value),
                this.MakeGridHeader(x => x.TrayBindVSN_lineCode).SetTitle(@Localizer["Page.所属产线编码"].Value),
                this.MakeGridHeader(x => x.TrayBindVSN_TrayStation).SetTitle(@Localizer["Page.当前工位"].Value),
                this.MakeGridHeader(x => x.TrayBindVSN_OnLineStation).SetTitle(@Localizer["Page.上线工位"].Value),
                this.MakeGridHeader(x => x.TrayBindVSN_OffLineStation).SetTitle(@Localizer["Page.下线工位"].Value),
                this.MakeGridHeader(x => x.TrayBindVSN_BindStatus).SetTitle(@Localizer["Page.托盘VSN绑定状态"].Value),
                this.MakeGridHeader(x => x.TrayBindVSN_increaseCode).SetTitle(@Localizer["Page.流水号"].Value),
                this.MakeGridHeader(x => x.TrayBindVSN_uploadflag).SetTitle(@Localizer["Page.上传标识"].Value),
                this.MakeGridHeader(x => x.TrayBindVSN_CreateTime).SetTitle(@Localizer["_Admin.CreateTime"].Value),
                this.MakeGridHeader(x => x.TrayBindVSN_UpdateTime).SetTitle(@Localizer["_Admin.UpdateTime"].Value),
                this.MakeGridHeader(x => x.TrayBindVSN_CreateBy).SetTitle(@Localizer["_Admin.CreateBy"].Value),
                this.MakeGridHeader(x => x.TrayBindVSN_UpdateBy).SetTitle(@Localizer["_Admin.UpdateBy"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<TrayBindVSN_View> GetSearchQuery()
        {
            var query = DC.Set<TrayBindVSN>()
                
                .CheckContain(Searcher.TrayCode, x=>x.TrayCode)
                .CheckContain(Searcher.VSN, x=>x.VSN)
                .CheckContain(Searcher.ScheduleCode, x=>x.ScheduleCode)
                .CheckContain(Searcher.OrderCode, x=>x.OrderCode)
                .CheckContain(Searcher.LineCode, x=>x.LineCode)
                .CheckContain(Searcher.TrayStation, x=>x.TrayStation)
                .CheckContain(Searcher.OnLineStation, x=>x.OnLineStation)
                .CheckContain(Searcher.OffLineStation, x=>x.OffLineStation)
                .CheckEqual(Searcher.BindStatus, x=>x.BindStatus)
                .CheckEqual(Searcher.IncreaseCode, x=>x.IncreaseCode)
                .CheckEqual(Searcher.Uploadflag, x=>x.Uploadflag)
                .CheckBetween(Searcher.CreateTime?.GetStartTime(), Searcher.CreateTime?.GetEndTime(), x => x.CreateTime, includeMax: false)
                .CheckBetween(Searcher.UpdateTime?.GetStartTime(), Searcher.UpdateTime?.GetEndTime(), x => x.UpdateTime, includeMax: false)
                .CheckContain(Searcher.CreateBy, x=>x.CreateBy)
                .CheckContain(Searcher.UpdateBy, x=>x.UpdateBy)
                .Select(x => new TrayBindVSN_View
                {
				    ID = x.ID,
                    
                    TrayBindVSN_TrayCode = x.TrayCode,
                    TrayBindVSN_VSN = x.VSN,
                    TrayBindVSN_ScheduleCode = x.ScheduleCode,
                    TrayBindVSN_orderCode = x.OrderCode,
                    TrayBindVSN_lineCode = x.LineCode,
                    TrayBindVSN_TrayStation = x.TrayStation,
                    TrayBindVSN_OnLineStation = x.OnLineStation,
                    TrayBindVSN_OffLineStation = x.OffLineStation,
                    TrayBindVSN_BindStatus = x.BindStatus,
                    TrayBindVSN_increaseCode = x.IncreaseCode,
                    TrayBindVSN_uploadflag = x.Uploadflag,
                    TrayBindVSN_CreateTime = x.CreateTime,
                    TrayBindVSN_UpdateTime = x.UpdateTime,
                    TrayBindVSN_CreateBy = x.CreateBy,
                    TrayBindVSN_UpdateBy = x.UpdateBy,
                })
                .OrderByDescending(x => x.ID);
            return query;
        }

        
    }
    public class TrayBindVSN_View: TrayBindVSN
    {
        
        public string TrayBindVSN_TrayCode { get; set; }
        public string TrayBindVSN_VSN { get; set; }
        public string TrayBindVSN_ScheduleCode { get; set; }
        public string TrayBindVSN_orderCode { get; set; }
        public string TrayBindVSN_lineCode { get; set; }
        public string TrayBindVSN_TrayStation { get; set; }
        public string TrayBindVSN_OnLineStation { get; set; }
        public string TrayBindVSN_OffLineStation { get; set; }
        public TrayBindStatusEnum? TrayBindVSN_BindStatus { get; set; }
        public int? TrayBindVSN_increaseCode { get; set; }
        public bool? TrayBindVSN_uploadflag { get; set; }
        public DateTime? TrayBindVSN_CreateTime { get; set; }
        public DateTime? TrayBindVSN_UpdateTime { get; set; }
        public string TrayBindVSN_CreateBy { get; set; }
        public string TrayBindVSN_UpdateBy { get; set; }

    }

}